package interfaces.language;

import main.InitGame;
import main.listeners.listenerClasses.LanguageListener;

import org.fenggui.binding.render.ImageFont;

import fileHandling.language.Lang;
import fileHandling.language.LanguageLoader;
import interfaces.superWidgets.InterfaceLabel;

public class LanguageLabel extends InterfaceLabel{
	
	protected Lang text;
	
	public LanguageLabel(Lang text, ImageFont font) {
		super(LanguageLoader.get(text), font);
		this.text = text;
		
		InitGame.get().addLanguageListener(new LanguageListener() {
			@Override
			public void languageChanged() {
				changeLanguage();
			}
		});
		
		layout();
	}
	
	public void setLangText(Lang text) {
		this.text = text;
		changeLanguage();
	}
	
	protected void changeLanguage() {
		setText(LanguageLoader.get(text));
		layout();
	}
}